package com.xzy.controller;

import com.xzy.entity.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author xzy.xiao
 * @date 2022/6/30  14:01
 */
@RestController
@RequestMapping("/user")
public class UserRestController {
    private final List<User> userList = new ArrayList<>(3);

    {
        userList.add(new User("1", "Jack", "123456", new Date()));
        userList.add(new User("2", "Mick", "456789", new Date()));
        userList.add(new User("3", "Tomi", "789012", null));
    }

    @GetMapping("/list")
    public ModelAndView userList() {
        return new ModelAndView("user/userList", "userList", userList);
    }
}
